import { getUserDetail } from "../api/myMusicApi"

const userStore = {
  namespaced: true,
  state: {
    profile: {},
    cookie: '',
    token: '',
    userDetail: {},// 用户的详细信息
  },
  mutations: {
    changeProfile(state, profile) {
      state.profile = profile
    },
    changeCookie(state, cookie) {
      state.cookie = cookie
    },
    changeToken(state, token) {
      state.token = token
    },
    changeUserDetail(state, userDetail) {
      state.userDetail = userDetail
    },
  },
  actions: {
    async getUserDetailActions(context) {
      console.log(context);
      let result = await getUserDetail(context.state.profile.userId)
      if (result.code === 200) {
        context.commit('changeUserDetail', result)
      }

    }
  }
}



export default userStore